
package ${package}.domain;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.hutool.core.bean.copier.CopyOptions;
import jakarta.persistence.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
<#if isNotNullColumns??>
import jakarta.validation.constraints.*;
</#if>
<#if hasDateAnnotation>
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import org.hibernate.annotations.*;
</#if>
<#if hasTimestamp>
import java.sql.Timestamp;
</#if>
<#if hasBigDecimal>
import java.math.BigDecimal;
</#if>
import java.io.Serializable;

/**
* @description /
* @author ${author}
* @date ${date}
**/
@Entity
@Getter
@Setter
@Accessors(chain = true)
@DynamicInsert
@DynamicUpdate
@Table(name="[${tableName}]")
@Schema(description = "${tableName}")
public class ${className} extends BaseEntity implements Serializable {
<#if columns??>
    <#list columns as column>

    <#if column.columnName?? && column.columnName != '' && (column.changeColumnName='createBy' || column.changeColumnName='createTime' || column.changeColumnName='updateBy' || column.changeColumnName='updateTime')>
    <#continue>
    </#if>

    <#if column.columnKey = 'PRI'>
    <#continue>
    </#if>
    @Column(name = "[${column.columnName}]"<#if column.columnKey = 'UNI'>,unique = true</#if><#if column.istNotNull && column.columnKey != 'PRI'>,nullable = false</#if>)
    <#if column.istNotNull && column.columnKey != 'PRI'>
        <#if column.columnType = 'String'>
    @NotBlank
        <#else>
    @NotNull
        </#if>
    </#if>
    <#if (column.dateAnnotation)?? && column.dateAnnotation != ''>
    <#if column.dateAnnotation = 'CreationTimestamp'>
    @CreationTimestamp
    <#else>
    @UpdateTimestamp
    </#if>
    </#if>
    <#if column.remark != ''>
    @Schema(description = "${column.remark}")
    <#else>
    @Schema(description = "${column.changeColumnName}")
    </#if>
    private ${column.columnType} ${column.changeColumnName};
    </#list>
</#if>

    public void copy(${className} source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
